# -*- coding: utf-8 -*-
# @Time     : 2021/10/18 10:47
# @Author   : JustFly
# @File     : tst.py
# @Software : PyCharm

# def get_baidu_hot():
#     """
#     :return: 返回百度热搜前30中的28个
#     """
#
#     option = webdriver.FirefoxOptions()
#     option.add_argument("--headless")  # 隐藏浏览器弹窗
#     option.add_argument("--no-send")
#
#     browser = webdriver.Firefox()
#     browser.get('https://top.baidu.com/board?tab=realtime')
#     r = browser.find_elements_by_xpath('//*[@id="sanRoot"]/main/div[2]/div/div[2]')  # F12 选中元素右键 copy 得到 Xpath
#
#     hot_data = [i.text.split("\n") for i in r]
#
#     hot_list = []
#     n = 0
#
#     for e in hot_data[0]:
#         if e == '热' or e == '新' or e == '沸':
#             hot_data[0].remove(e)
#         else:
#             n += 1
#             if n % 5 == 0:
#                 hot_list.append(hot_data[0][
#                                 n - 5: n])  # ['1', '4992729', '热搜指数', '河北大巴坠河事故致14人遇难', '10月11日，河北石家庄市平山县一辆载51人的大巴车落水。截至12日下午2时40分，最后一名失联人员被找到，已无生命体征... 查看更多>']
#
#     return hot_list


import requests

url = "https://top.baidu.com/board?tab=realtime"
res = requests.get(url).content.decode("utf-8")
print(res)
